package Homework_0709.src.practice2;

/**
 * @author caesar
 * @date 2025/7/9
 * @Description:
 * @apiNote
 */
public class ShapeFactory {
    // 成员内部类 - 圆形
    private static class Circle implements Shape {
        @Override
        public void draw() {
            System.out.println("Drawing a circle.");
        }
    }

    // 成员内部类 - 正方形
    private static class Square implements Shape {
        @Override
        public void draw() {
            System.out.println("Drawing a square.");
        }
    }

    // 成员内部类 - 三角形
    private static class Triangle implements Shape {
        @Override
        public void draw() {
            System.out.println("Drawing a triangle.");
        }
    }

    // 工厂方法，根据类型创建形状
    public static Shape getShape(String shapeType) {
        switch(shapeType){
            case "circle" :return new Circle();
            case "square":return new Square();
            case "triangle":return new Triangle();
            default: return null;
        }
    }
}
